<%@page import="java.util.*" %>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="../include/tag.jsp" %>
<!DOCTYPE html>
<html lang="zh">
<head>
    <title>服务订购</title>
    <link rel="stylesheet" href="${ctx}/css/common/list.css">
    <link rel="stylesheet" href="${ctx}/css/common/table.css">
    <%@include file="../include/commonFile.jsp" %>
</head>
<body>
<!--头部-->
<%@include file="../include/header.jsp" %>
<div class="index-outside">
    <%@include file="../include/sidebar.jsp" %>
    <!--内容-->
    <section>
        <div class="section-main">
            <form class="layui-form" action="${ctx}/serviceOrder/list.do" id="myForm" method="post">
                <input type="hidden" name="pageNo" id="pageNo"/>
            </form>
            <div class="list-content">
                <ul class="num mt10">
                    <div class="l">
                        <li class="f16">共<span class="red">${page.totalCount}</span>条数据</li>
                    </div>
                    <p class="cl"></p>
                </ul>
                <div class="cl">
                    <table class="layui-table">
                        <colgroup>
                            <col width="135px">
                            <col width="170px">
                            <col width="115px">
                            <col width="115px">
                            <col width="120px">
                            <col width="110px">
                        </colgroup>
                        <thead>
                        <tr>
                            <th>创建时间</th>
                            <th>服务内容</th>
                            <th>费用（元）</th>
                            <th>服务抵扣（元）</th>
                            <th>订单状态</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <c:forEach var="packageMember" items="${list}" varStatus="st">
                            <tr>
                                <td><fmt:formatDate value="${packageMember.createDate}"
                                                    pattern="yyyy-MM-dd HH:mm"/></td>
                                <td>${packageMember.systemType == 1? '社群':'众筹'}系统 —— ${packageMember.packageName}</td>
                                <td>${packageMember.price}</td>
                                <td>${packageMember.deductionAmount}</td>
                                <td>
                                    <c:choose>
                                        <c:when test="${packageMember.status == 2}">
                                            订单已取消
                                        </c:when>
                                        <c:when test="${packageMember.payWay==3 && packageMember.auditStatus==1}">
                                            审核中
                                        </c:when>
                                        <c:when test="${packageMember.payWay==3 && packageMember.auditStatus==2}">
                                            审核成功
                                        </c:when>
                                        <c:when test="${packageMember.payWay==3 && packageMember.auditStatus==3}">
                                            审核失败
                                        </c:when>
                                        <c:when test="${packageMember.payStatus==1}">
                                            待支付
                                        </c:when>
                                        <c:when test="${packageMember.payStatus==2}">
                                            订购成功
                                        </c:when>
                                        <c:when test="${packageMember.payStatus==3}">
                                            支付失败
                                        </c:when>
                                    </c:choose>
                                </td>
                                <td>
                                    <c:if test="${packageMember.status != 2 && packageMember.payStatus!=2 && packageMember.auditStatus!=2}">
                                        <c:if test="${packageMember.payWay!=3 && packageMember.payStatus==1}">
                                            <a class="layui-btn layui-btn-danger"
                                               href="${ctx}/serviceOrder/info.do?packageMemberId=${packageMember.id}">去支付</a><span
                                                style="margin: auto 10px;">|</span>
                                        </c:if>
                                        <c:if test="${packageMember.payStatus==1}">
                                            <a href="javascript:cancel('${packageMember.id}','1')"
                                               style="color: blue">取消</a>
                                        </c:if>
                                        <c:if test="${packageMember.auditStatus == 1}">
                                            <a href="javascript:cancel('${packageMember.id}','2')"
                                               style="color: blue">取消</a>
                                        </c:if>
                                    </c:if>
                                </td>
                            </tr>
                        </c:forEach>
                        </tbody>
                    </table>
                    <div id="page_content" class="page-container"></div>
                </div>
            </div>
        </div><!--底部-->
        <%@include file="../include/footer.jsp" %>
    </section>
</div>

<script type="text/javascript" src="${ctx}/script/common/list.js"></script>
<script type="text/javascript" src="${ctx}/script/common/table_option.js"></script>
<script type="text/javascript">
    $(function () {
        //加载分页
        loadPageNew({
            elem: 'page_content',
            totalCount: '${page.totalCount}',
            limit: '${page.limit}',
            page: '${page.page}'
        });
    })


        function cancel(id, sign) {
            var str = '此订单尚未支付，确定要取消吗？';
            if (sign == '2') {
                str = '此订单正在审核中，确定要取消吗？';
            }
            layer.confirm(str, {
                icon: 3,
                title: '系统提示'
            }, function (index) {
                $.post("${ctx}/serviceOrder/cancelOrder.do", {
                    packageMemberId: id,
                }, function (data) {
                    if (data.success) {
                        util.layerMsgSuccess("操作成功", function () {
                            window.location.reload();
                        })
                    } else {
                        util.layerMsgError("操作失败")
                    }
                });
            });
        }
</script>
<script type="text/javascript">
    txz.initHeader({
        nav: [{
            name: '服务订购',
            curr: true
        }],
        info: '<span class="f14 gray">官方咨询电话：4008-771-663</span>'
    });
</script>
</body>
</html>